package test.com.corecode.common.crypto;

import com.corecode.common.crypto.AlgorithmConstants;
import com.corecode.common.crypto.AlgorithmFactory;
import com.corecode.common.crypto.AlgorithmUtils;

public class AlgorithmDemo {
	
	public static void main(String[] args) {
	
		AlgorithmUtils utils = AlgorithmFactory
				.createAlgorithmUtils(AlgorithmConstants.BASE64_ALGORITHM);
		AlgorithmDemo.show(utils);
		
		utils.setAlgorithm(AlgorithmConstants.AES_ALGORITHM);
		AlgorithmDemo.show(utils);
		
		utils.setAlgorithm(AlgorithmConstants.MD5_ALGORITHM);
		AlgorithmDemo.show(utils);
	}
	
	private static void show(AlgorithmUtils utils) {
		String str = "";
		try {
			str = utils.encryptedData("luowei");
			System.out.println(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("----------end -----------");
	}
}
